package com.shyroke.daydayzhuansvc.util;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;


/**
 * 类名 ：
 * 用法 ：
 * 创建人 ： shyroke
 * 时间：2018/8/16 10:30
 */
@Data
public class R implements Serializable {
    private  boolean flag;
    private  String message;
    private Map<String,Object> data;

    public R(boolean flag, String message){
        this.flag = flag;
        this.message = message;
    }

    public R(boolean flag, String message, String key, Object value){
        this.flag = flag;
        this.message = message;
        if(data==null){
            data = new HashMap<>();
        }
        data.put(key,value);
    }

    public static R ok(String message){
           R r = new R(true,message);
           return r;
    }

    public static R error(String message){
        R r = new R(false,message);
        return r;
    }


    public static R ok(String key,Object value){
            R r = new R(true,"",key,value);
            return r;
    }

}
